accel34 2.2.0
Loading...
Searching...
No Matches
accel34


Accel 34 Click

Accel 34 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Feb 2025.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of Accel 34 Click board by reading and displaying the accelerometer data (X, Y, and Z axis) and a temperature measurement in degrees Celsius.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Accel34

Example Key Functions

  • accel34_cfg_setup This function initializes Click configuration structure to initial values.
    void accel34_cfg_setup(accel34_cfg_t *cfg)
    Accel 34 configuration object setup function.
    Accel 34 Click configuration object.
    Definition accel34.h:337
  • accel34_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t accel34_init ( accel34_t *ctx, accel34_cfg_t *cfg );
    err_t accel34_init(accel34_t *ctx, accel34_cfg_t *cfg)
    Accel 34 initialization function.
    Accel 34 Click context object.
    Definition accel34.h:317
  • accel34_default_cfg This function executes a default configuration of Accel 34 Click board.
    err_t accel34_default_cfg(accel34_t *ctx)
    Accel 34 default configuration function.
  • accel34_set_accel_fsr This function sets the accel measurement full scale range.
    err_t accel34_set_accel_fsr ( accel34_t *ctx, uint8_t fsr );
    err_t accel34_set_accel_fsr(accel34_t *ctx, uint8_t fsr)
    Accel 34 set full-scale range function.
  • accel34_get_data This function reads both accelerometer and temperature data from the device.
    err_t accel34_get_data ( accel34_t *ctx, accel34_data_t *data_out );
    err_t accel34_get_data(accel34_t *ctx, accel34_data_t *data_out)
    Accel 34 get accelerometer and temperature data function.
    Accel 34 Click data structure.
    Definition accel34.h:366

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
accel34_cfg_t accel34_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel34_cfg_setup( &accel34_cfg );
ACCEL34_MAP_MIKROBUS( accel34_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == accel34_init( &accel34, &accel34_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ACCEL34_ERROR == accel34_default_cfg ( &accel34 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ ACCEL34_ERROR
Definition accel34.h:379
#define ACCEL34_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition accel34.h:303
void application_init(void)
Definition main.c:30

Application Task

Reads the accelerometer and temperature measurements. The results are displayed on the USB UART every 100 ms.

void application_task ( void )
{
accel34_data_t meas_data;
if ( ACCEL34_OK == accel34_get_data ( &accel34, &meas_data ) )
{
log_printf( &logger, " Accel X: %.3f g\r\n", meas_data.accel.x );
log_printf( &logger, " Accel Y: %.3f g\r\n", meas_data.accel.y );
log_printf( &logger, " Accel Z: %.3f g\r\n", meas_data.accel.z );
log_printf( &logger, " Temperature: %.1f degC\r\n\n", meas_data.temperature );
Delay_ms ( 100 );
}
}
@ ACCEL34_OK
Definition accel34.h:378
void application_task(void)
Definition main.c:66
float y
Definition accel34.h:356
float x
Definition accel34.h:355
float z
Definition accel34.h:357
accel34_axes_t accel
Definition accel34.h:367
float temperature
Definition accel34.h:368

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.